package com.mq.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {


    @Insert("INSERT INTO orders " +
            "(user_id, flight_id, status, create_time, payment_deadline, total_price) " +
            "VALUES (#{userId}, #{flightId}, 1, NOW(), DATE_ADD(NOW(), INTERVAL 3 MINUTE), #{price})")
    void createOrder(Integer userId, Integer flightId,Double price);

    @Insert("update orders set status=4 where flight_id=#{orderId}")
    void CancelLockOrder(Integer userId, Integer orderId);
    @Select("select order_id, user_id, flight_id, recommendation_id, status, create_time, payment_deadline, total_price from orders where user_id=#{userId}")
    List<Map<String, Object>> getOrderList(Integer userId);
    @Select("select flight_id from orders where order_id=#{orderId}")
    Integer getFLightsByFlightIdInOrders(Integer orderId);
    @Select("select total_price from orders where order_id=#{orderId}")
    Double getPriceByOrderId(Integer orderId);
}
